package org.example.myleet.learn.bank;

import java.math.BigDecimal;
import java.util.Random;

public class BankTest {
    public static void main(String[] args) {
        Bank bank = new Bank();
        int size = bank.getSize();
        Random rand = new Random();
        for (int i = 0; i < 1000; ++i) {
            long id = i;
            Thread t = new Thread(() -> {
                int from = rand.nextInt(size);
                int to = rand.nextInt(size);
                if (from == to) {
                    if (to == size - 1) {
                        to = from - 1;
                    } else {
                        to = from + 1;
                    }
                }
                bank.transfer(id, from, to, BigDecimal.valueOf(10));
            });
            t.start();
        }
        System.out.println("all threads are started, please wait...");
    }
}
